package com.kinghunt.misp.common.enums.userx;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 用户注册类型枚举
 */
public enum UserCreateTypeEnum {
    SELF_REG(1, "自行注册"),
    ADMIN_REG(2, "管理员注册"),
    AUTO_BATCH(3, "自动批量"),
    IMPORT_BATCH(4, "批量导入"),
    WECHAT_REG(5, "微信小程序注册");

    @Getter
    private Integer type;
    @Getter
    private String desc;

    UserCreateTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    private final static Map<Integer, UserCreateTypeEnum> map = new HashMap<>(8);
    static {
        for (UserCreateTypeEnum e : UserCreateTypeEnum.values()) {
            map.put(e.getType(), e);
        }
    }

    public static UserCreateTypeEnum getByType(Integer type) {
        if (Objects.isNull(type)) {
            return null;
        }
        return map.get(type);
    }
}
